package com.cssw.fyzb.busi.api.acct;

import com.cssw.fyzb.busi.api.user.GetUserInfo;
import com.cssw.fyzb.busi.service.acct.AcctService;
import com.cssw.fyzb.busi.service.team.TeamService;
import com.cssw.fyzb.core.model.dodb.Acct;
import com.cssw.fyzb.core.model.dodb.AcctType;
import com.cssw.fyzb.core.model.dodb.TeamGzPrice;
import com.cssw.fyzb.core.model.vo.acct.AcctGzGlobalVo;
import com.cssw.fyzb.core.model.vo.acct.TeamGzPriceVo;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


/**
 * 查询果子价格列表
 *
 * asa
 */
@Function(description = "查询果子价格列表", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户标识", required = true)
})
@Component
public class ListTeamGzPrice implements Action {

    @Autowired
    private AcctService acctService;

    private static final Logger logger = LoggerFactory.getLogger(GetUserInfo.class);
    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");

        try {
            List<TeamGzPrice> teamGzPrices = acctService.listTeamGzPrice();
            List<TeamGzPriceVo> vos = new ArrayList<>();
            TeamGzPriceVo vo = null;
            for (TeamGzPrice teamGzPrice: teamGzPrices){
                vo = new TeamGzPriceVo();
                vo.setNumName(teamGzPrice.getNumName());
                vo.setMaxNum(teamGzPrice.getMaxNum());
                vo.setMinNum(teamGzPrice.getMinNum());
                vo.setPrice(teamGzPrice.getPrice());
                vo.setMonthLimitNum(teamGzPrice.getMonthLimitNum());
                vos.add(vo);
            }

           return Response.success().put("list", vos);
        } catch (Exception e) {
            logger.error("", e);
            return Response.fail("操作异常");
        }
    }
}
